﻿<Window x:Class="UniversalGrid.ConfigWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        xmlns:universalGrid="clr-namespace:UniversalGrid"
        xmlns:fontDialogSample="clr-namespace:FontDialogSample;assembly=FontChooserControl"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
        Title="Configuration" Loaded="ConfigWindow_OnLoaded" SizeToContent="WidthAndHeight" ResizeMode="NoResize"
        d:DataContext="{d:DesignInstance universalGrid:GridListViewModel}" Icon="/Icons/grid3.ico">
    <Window.Resources>
        <universalGrid:EmptyStringToNullConverter x:Key="colConv"></universalGrid:EmptyStringToNullConverter>
        <universalGrid:CalculationTypeToVisibilityConverter x:Key="vizConv"/>
        <universalGrid:FontSizeValueConverter x:Key="fontConv"></universalGrid:FontSizeValueConverter>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition Width="300"/>
        </Grid.ColumnDefinitions>
        <Menu Grid.Row="0" Grid.ColumnSpan="2">
            <MenuItem Header="_File">
                <MenuItem Header="_Open" Click="OpenMenuItem_OnClick"/>
                <MenuItem Header="_Save" Click="SaveMenuItem_OnClick"/>
                <MenuItem Header="_Exit" Click="QuitMenuItem_OnClick"/>
            </MenuItem>
            <MenuItem Header="_Options">
                <MenuItem Header="_Opaque Background" IsCheckable="True" IsChecked="{Binding IsBackgroundOpaque}"/>
                <MenuItem Header="_Click-Through Mode" IsCheckable="True" IsChecked="{Binding IsInClickThroughMode}"/>
                <MenuItem Header="_Show Blindtext" IsCheckable="True" IsChecked="{Binding IsShowingBlindtext}"></MenuItem>
            </MenuItem>
        </Menu>
        <StackPanel Orientation="Vertical" Grid.Column="0" Grid.Row="1">
            <ListBox ItemsSource="{Binding GridList}" x:Name="lbGrids" SelectedItem="{Binding SelectedGridViewModel}" DisplayMemberPath="Name" Height="390" Margin="5"></ListBox>
            <Grid Margin="5 0 5 5">
                <Button Command="{Binding AddGridCommand}" HorizontalAlignment="Left">Add Grid</Button>
                <Button Command="{Binding RemoveGridCommand}" HorizontalAlignment="Right">Remove Grid</Button>
            </Grid>
        </StackPanel>
        <TabControl VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="1"  x:Name="detailPanel" DataContext="{Binding ElementName=lbGrids, Path=SelectedItem}" d:DataContext="{d:DesignInstance universalGrid:GridViewModel}" Margin="0 5 5 5">
            <TabItem Header="General">
                <StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
                        <TextBlock Margin="0,0,10,0">Name</TextBlock>
                        <TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" Width="150"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Width</TextBlock>
                        <TextBox Text="{Binding Width, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="150"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Height</TextBlock>
                        <TextBox Text="{Binding Height, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="150"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Horizontal Alignment</TextBlock>
                        <ComboBox SelectedItem="{Binding HorizontalAlignment}" Width="150">
                            <HorizontalAlignment>Left</HorizontalAlignment>
                            <HorizontalAlignment>Right</HorizontalAlignment>
                            <HorizontalAlignment>Center</HorizontalAlignment>
                            <HorizontalAlignment>Stretch</HorizontalAlignment>
                        </ComboBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Vertical Alignment</TextBlock>
                        <ComboBox SelectedItem="{Binding VerticalAlignment}" Width="150">
                            <VerticalAlignment>Bottom</VerticalAlignment>
                            <VerticalAlignment>Center</VerticalAlignment>
                            <VerticalAlignment>Stretch</VerticalAlignment>
                            <VerticalAlignment>Top</VerticalAlignment>
                        </ComboBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Gutter Background</TextBlock>
                        <xctk:ColorPicker Width="150" DisplayColorAndName="True" SelectedColor="{Binding GutterBackground}"></xctk:ColorPicker>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Gutter Opacity</TextBlock>
                        <Slider Width="150" Minimum="0" Maximum="1" IsSelectionRangeEnabled="False" Value="{Binding GutterOpacity}"></Slider>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Grid Width</TextBlock>
                        <TextBox Text="{Binding GridThickness, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="150"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Grid Color</TextBlock>
                        <xctk:ColorPicker Width="150" DisplayColorAndName="True" SelectedColor="{Binding GridColor}"></xctk:ColorPicker>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Grid Opacity</TextBlock>
                        <Slider Width="150" Minimum="0" Maximum="1" IsSelectionRangeEnabled="False" Value="{Binding GridOpacity}"></Slider>
                    </StackPanel>
                    <GroupBox Header="Baseline Grid">
                        <StackPanel>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 5 5 5">
                                <TextBlock Margin="0,0,10,0">Grid Width</TextBlock>
                                <TextBox Text="{Binding BaselineGridThickness, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="150"></TextBox>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 0 5 5">
                                <TextBlock Margin="0,0,10,0">Grid Color</TextBlock>
                                <xctk:ColorPicker Width="150" DisplayColorAndName="True" SelectedColor="{Binding BaselineGridColor}"></xctk:ColorPicker>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 0 5 5">
                                <TextBlock Margin="0,0,10,0">Grid Opacity</TextBlock>
                                <Slider Width="150" Minimum="0" Maximum="1" IsSelectionRangeEnabled="False" Value="{Binding BaselineGridOpacity}"></Slider>
                            </StackPanel>
                        </StackPanel>
                    </GroupBox>
                </StackPanel>
            </TabItem>
            <TabItem Header="Margins">
                <StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
                        <TextBlock Margin="0,0,10,0">Left</TextBlock>
                        <TextBox Text="{Binding LeftMargin, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="150" Margin="0,0,5,0"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
                        <TextBlock Margin="0,0,10,0">Top</TextBlock>
                        <TextBox Text="{Binding TopMargin, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="150" Margin="0,0,5,0"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
                        <TextBlock Margin="0,0,10,0">Right</TextBlock>
                        <TextBox Text="{Binding RightMargin, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="150" Margin="0,0,5,0"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
                        <TextBlock Margin="0,0,10,0">Bottom</TextBlock>
                        <TextBox Text="{Binding BottomMargin, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="150" Margin="0,0,5,0"></TextBox>
                    </StackPanel>
                </StackPanel>    
            </TabItem>
            <TabItem Header="Visibility">
                <StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
                        <TextBlock Margin="0,0,10,0">Minimum Width</TextBlock>
                        <TextBox Text="{Binding MinWidth, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="150" Margin="0,0,5,0"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
                        <TextBlock Margin="0,0,10,0">Maximum Width</TextBlock>
                        <TextBox Text="{Binding MaxWidth, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="150" Margin="0,0,5,0"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
                        <TextBlock Margin="0,0,10,0">Minimum Height</TextBlock>
                        <TextBox Text="{Binding MinHeight, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="150" Margin="0,0,5,0"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
                        <TextBlock Margin="0,0,10,0">Maximum Height</TextBlock>
                        <TextBox Text="{Binding MaxHeight, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="150" Margin="0,0,5,0"></TextBox>
                    </StackPanel>
                </StackPanel>
            </TabItem>
            <TabItem Header="Rows">
                <StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 5 5 5">
                        <TextBlock Margin="0,0,10,0">Type</TextBlock>
                        <ComboBox SelectedItem="{Binding RowCalculationType}" Width="150">
                            <universalGrid:RowCalculationType>FixedHeight</universalGrid:RowCalculationType>
                            <universalGrid:RowCalculationType>FixedCount</universalGrid:RowCalculationType>
                            <universalGrid:RowCalculationType>FixedBoth</universalGrid:RowCalculationType>
                            <universalGrid:RowCalculationType>Baseline</universalGrid:RowCalculationType>
                        </ComboBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding RowCalculationType,ConverterParameter='FixedCount FixedBoth', Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Row Count</TextBlock>
                        <TextBox Text="{Binding RowCount, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="150"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding RowCalculationType,ConverterParameter='FixedHeight FixedBoth' , Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Row Height</TextBlock>
                        <TextBox Text="{Binding RowHeight, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="120" Margin="0,0,5,0"></TextBox>
                        <TextBlock Margin="0,2,0,0">Pixel</TextBlock>
                    </StackPanel>
                    <GroupBox Header="Font" Visibility="{Binding RowCalculationType,ConverterParameter=Baseline, Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                        <StackPanel>
                            <Button Click="Button_Click" Visibility="{Binding RowCalculationType,ConverterParameter=Baseline, Converter={StaticResource vizConv}}"  Margin="5 5 5 5">Choose Font</Button>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding RowCalculationType,ConverterParameter=Baseline, Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                                <TextBlock Margin="0,0,10,0">Font Family</TextBlock>
                                <TextBlock Width="150" Text="{Binding FontFamily, FallbackValue='', UpdateSourceTrigger=PropertyChanged}"></TextBlock>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding RowCalculationType,ConverterParameter=Baseline, Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                                <TextBlock Margin="0,0,10,0">Font Size</TextBlock>
                                <TextBlock Width="150" Text="{Binding FontSize, FallbackValue='', Converter={StaticResource fontConv}, UpdateSourceTrigger=PropertyChanged}"></TextBlock>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding RowCalculationType,ConverterParameter=Baseline, Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                                <TextBlock Margin="0,0,10,0">Font Style</TextBlock>
                                <TextBlock Width="150" Text="{Binding FontStyle, FallbackValue='', UpdateSourceTrigger=PropertyChanged}"></TextBlock>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding RowCalculationType,ConverterParameter=Baseline, Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                                <TextBlock Margin="0,0,10,0">Font Weight</TextBlock>
                                <TextBlock Width="150" Text="{Binding FontWeight, FallbackValue='', UpdateSourceTrigger=PropertyChanged}"></TextBlock>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding RowCalculationType,ConverterParameter=Baseline, Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                                <TextBlock Margin="0,0,10,0">Font Stretch</TextBlock>
                                <TextBlock Width="150" Text="{Binding FontStretch, FallbackValue='', UpdateSourceTrigger=PropertyChanged}"></TextBlock>
                            </StackPanel>
                        </StackPanel>
                    </GroupBox>

                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding RowCalculationType,ConverterParameter=Baseline, Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Line Height</TextBlock>
                        <TextBox Width="150" Text="{Binding LineHeight, FallbackValue='', UpdateSourceTrigger=PropertyChanged}"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding RowCalculationType,ConverterParameter=Baseline, Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Cell Height</TextBlock>
                        <TextBox Width="150" Text="{Binding CellHeight, FallbackValue='', UpdateSourceTrigger=PropertyChanged}"></TextBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding RowCalculationType,ConverterParameter=Baseline, Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Baseline Grid Visible</TextBlock>
                        <CheckBox Width="150" IsChecked="{Binding IsBaselineGridVisible}"></CheckBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding RowCalculationType,ConverterParameter=Baseline, Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">First Line in Cell</TextBlock>
                        <CheckBox Width="150" IsChecked="{Binding IsFirstLineInCell}"></CheckBox>
                    </StackPanel>
                </StackPanel>
            </TabItem>
            <TabItem Header="Columns">
                <StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 5 5 5">
                        <TextBlock Margin="0,0,10,0">Type</TextBlock>
                        <ComboBox SelectedItem="{Binding ColumnCalculationType}" Width="150">
                            <universalGrid:ColumnCalculationType>FixedWidth</universalGrid:ColumnCalculationType>
                            <universalGrid:ColumnCalculationType>FixedCount</universalGrid:ColumnCalculationType>
                            <universalGrid:ColumnCalculationType>FixedBoth</universalGrid:ColumnCalculationType>
                        </ComboBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding ColumnCalculationType,ConverterParameter='FixedWidth FixedBoth', Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Column Width</TextBlock>
                        <TextBox Text="{Binding ColumnWidth, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="120" Margin="0,0,5,0"></TextBox>
                        <TextBlock Margin="0,2,0,0">Pixel</TextBlock>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding ColumnCalculationType,ConverterParameter='FixedCount FixedBoth', Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Column Count</TextBlock>
                        <TextBox Text="{Binding ColumnCount, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="150"></TextBox>
                    </StackPanel>
                </StackPanel>
            </TabItem>
            <TabItem Header="Gutter">
                <StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5 5 5 5">
                        <TextBlock Margin="0,0,10,0">Type</TextBlock>
                        <ComboBox SelectedItem="{Binding GutterCalculationType}" Width="150">
                            <universalGrid:GutterCalculationType>Baseline</universalGrid:GutterCalculationType>
                            <universalGrid:GutterCalculationType>Fixed</universalGrid:GutterCalculationType>
                            <universalGrid:GutterCalculationType>Ratio</universalGrid:GutterCalculationType>
                        </ComboBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"  Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Start with Gutter</TextBlock>
                        <CheckBox Width="150" IsChecked="{Binding IsStartingWithGutter}"></CheckBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding GutterCalculationType,ConverterParameter='Fixed Ratio Baseline', Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Gutter Width</TextBlock>
                        <TextBox Text="{Binding GutterWidth, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="120" Margin="0,0,5,0"></TextBox>
                        <TextBlock Width="25" Visibility="{Binding GutterCalculationType,ConverterParameter='Fixed', Converter={StaticResource vizConv}}" Margin="0,2,0,0">Pixel</TextBlock>
                        <TextBlock Width="25" Visibility="{Binding GutterCalculationType,ConverterParameter='Ratio', Converter={StaticResource vizConv}}" Margin="0,2,0,0">%</TextBlock>
                        <TextBlock Width="25" Visibility="{Binding GutterCalculationType,ConverterParameter='Baseline', Converter={StaticResource vizConv}}" Margin="0,2,0,0">Line</TextBlock>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding GutterCalculationType,ConverterParameter='Fixed Ratio Baseline', Converter={StaticResource vizConv}}" Margin="5 0 5 5">
                        <TextBlock Margin="0,0,10,0">Gutter Height</TextBlock>
                        <TextBox Text="{Binding GutterHeight, Converter={StaticResource colConv}, UpdateSourceTrigger=PropertyChanged}" Width="120" Margin="0,0,5,0"></TextBox>
                        <TextBlock Width="25" Visibility="{Binding GutterCalculationType,ConverterParameter='Fixed', Converter={StaticResource vizConv}}" Margin="0,2,0,0">Pixel</TextBlock>
                        <TextBlock Width="25" Visibility="{Binding GutterCalculationType,ConverterParameter='Ratio', Converter={StaticResource vizConv}}" Margin="0,2,0,0">%</TextBlock>
                        <TextBlock Width="25" Visibility="{Binding GutterCalculationType,ConverterParameter='Baseline', Converter={StaticResource vizConv}}" Margin="0,2,0,0">Line</TextBlock>
                    </StackPanel>
                </StackPanel>
            </TabItem>
        </TabControl>
    </Grid>
</Window>
